package main

import (
	"bufio"
	"fmt"
	"net"
	"os"
)

func main() {
	conn, err := net.Dial("tcp", "127.0.0.1:6000")
	if err != nil {
		fmt.Println("connect error", err)
		return
	}
	for {
		fmt.Println("client:")
		buff := bufio.NewScanner(os.Stdin)
		buff.Scan()
		input := buff.Text()
		if input == "exit" {

			// conn.Close()
			break

		}
		z, _ := conn.Write([]byte(input))

		var tmp [128]byte
		n, err := conn.Read(tmp[:])
		if err != nil {
			fmt.Println("read err", err)
			continue
		}
		fmt.Println("read from server messages:", string(tmp[:n]))

	}
	defer conn.Close()

}
